import React, { useState } from "react";

const WithButton = ({ render }) => {
  const [count, setCount] = useState(0);
  const handleClick = () => {
    setCount(count + 1);
  };
  return render({ count, handleClick });
};

const MyButtonComponent = () => {
  return (
    <WithButton
      render={({ count, handleClick }) => (
        <button onClick={handleClick}>
          Click me!I've been clicked {count} times
        </button>
      )}
    ></WithButton>
  );
};

export default MyButtonComponent;
